﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using LIMS.Entities;
using LIMS.Shared;

namespace LIMS.Windows
{
    public partial class Login_old : LIMSPageBase<UserManagementPagePresenter> ,IUserManagementPageView
    //public partial class Login : Form
    {
        public Login_old()
        {
            InitializeComponent();
        }

        private void btnLogin_Click(object sender, EventArgs e)
        {
            User oUser = new User();
            string sMessage = string.Empty;
            //oUser = this.Presenter.GetUserByUserName(txtUserName.Text.Trim());
            if (String.IsNullOrEmpty(txtUserName.Text.Trim ()))
            {
                MessageBox.Show("User name cannot empty","Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
                txtUserName.Focus();
                return;
            }
            if (String.IsNullOrEmpty(txtPassword.Text.Trim()))
            {
                MessageBox.Show("Password cannot be empty", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtPassword.Focus();
                return;
            }
            if (this.Presenter.ValidateUser(txtUserName.Text.Trim(), txtPassword.Text.Trim(), "", ref oUser, ref sMessage))
            {
                this.Hide();
                Dashboard oForm = new Dashboard();
                oForm.ShowDialog();

            }
            else
            {
                MessageBox.Show(sMessage,"Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
                txtPassword.Text = "";
                txtUserName.Focus();
                txtUserName.SelectAll();
                
            }
            
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }



        #region IUserManagementPageView Members

        public int CurrentIndex
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public void FillPageData()
        {
            throw new NotImplementedException();
        }

        public GridViewData GridData
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public Dictionary<string, string> PageData
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public void ShowMessage(MessageType type, string sMessage)
        {
            throw new NotImplementedException();
        }

        public List<User> Users
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        #endregion
    }
}
